//
// Created by LiuDongPeng on 2023/11/14.
//

#include "motor.h"

motor::motor(int poleNum)
{

}


void motor::clark_transform()
{
    arm_clarke_f32(ia, ib, &ialpha, &ibeta);
}
void motor::inv_clark_transform()
{
    arm_inv_clarke_f32(ialpha, ibeta, &ia, &ib);
    ic = -ia - ib;
}

void motor::park_transform()
{
    arm_park_f32(ialpha, ibeta, &id, &iq, sinAngle, cosAngle);
}
void motor::inv_park_transform()
{
    arm_inv_park_f32(id, iq, &ialpha, &ibeta, sinAngle, cosAngle);
}

void motor::get_angle()
{
    mangle = bsp_get_motor_angle();
    eangle = fmodf(mangle * m_poleNum, 360.0);

    sinAngle = arm_sin_f32(eangle);
    cosAngle = arm_cos_f32(eangle);
}

void motor::get_iab()
{
    bsp_get_phase_current(&ia, &ib, &ic);
    //ic = -ia - ib;
}